package com.rivulet.foreign.config;

import com.rivulet.foreign.pojo.User;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.UsernamePasswordToken;

/**
 * {自建token}
 *
 * @author xujiac
 * @create 2021/7/19
 * @since 1.0.0
 */
public class UsernamePasswordIdentityToken extends UsernamePasswordToken {
    private String username;
    private String password;
    private Integer identity;

    public UsernamePasswordIdentityToken(User user) {
        this.username = user.getUser_id();
        this.password = user.getPassword();
        this.identity = user.getIdentity();
    }

    @Override
    public Object getPrincipal() {
        return username;
    }

    @Override
    public Object getCredentials() {
        return password;
    }

    @Override
    public String toString() {
        return identity.toString();
    }
}
